package com.yunfangdata.service.impl;

import com.yunfangdata.domain.Studentstatus;
import com.yunfangdata.mapper.StudentstatusMapper;
import com.yunfangdata.query.QueryObject;
import com.yunfangdata.query.StudentstatusObject;
import com.yunfangdata.service.IStudentstatusService;
import com.yunfangdata.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class StudentstatusServiceImpl implements IStudentstatusService {

    @Autowired
    private StudentstatusMapper mapper ;
    @Override
    public void save(Studentstatus entity) {
        mapper.insert(entity);
    }

    @Override
    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Studentstatus entity) {
        mapper.updateByPrimaryKey(entity);
    }

    @Override
    public Studentstatus get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Studentstatus> list() {
        return mapper.selectAll();
    }

    @Override
    public PageResult query(StudentstatusObject qo) {
        int total = mapper.queryForCount(qo);

        if (total == 0){
            return new PageResult();
        }
        List<Studentstatus> rows = mapper.queryForList(qo);
        return new PageResult(total,rows);
    }

    @Override
    public void changeState(Long id) {
        mapper.changeState(id);
    }
}